#ifndef SUP_CLIENT_
#define SUP_CLIENT_
#include "ct_tcp_client.h"
#include "ctMisc.h"
#include "SuperCommandIn.h"

///服务器网络连接类型
enum eNetServiceType {
        eNetServiceType_TCP = 0,
        eNetServiceType_UDP,
};

///管理服务器的连接客户端类
class SuperCli: 
        public ctTCPBufferClient, 
        public MessageQueue
{
        public:
                SuperCli(void *host, const eNetServiceType type):
                        ctTCPBufferClient("Super Client"), 
                        verified_(false), 
                        host_type_(type),
                        host_ptr_(host)
                        {
                        }

                ~SuperCli() {};

                void run();
                bool msgParse(const Cmd::t_NullCmd *cmd, const uint32_t len);
                bool cmdMsgParse(const Cmd::t_NullCmd *cmd, const uint32_t len);
                bool msg_parse_startup(const Cmd::t_NullCmd *cmd, const uint32_t len);
                bool wait_sync();
                void host_validate();
                void get_host_info(uint16_t &srvtype, uint16_t &srvid);
                void host_terminate();
                void host_set_srv_info(const Cmd::Super::stStartUpResponse *ptCmd);
                void host_add_srv_entry(ServerEntryNew &entry);
                void host_proc_new_srv(uint16_t type, uint16_t id);
                bool host_msg_parse_super(const Cmd::t_NullCmd *pNullCmd, const uint32_t nCmdLen);

        private:
                bool verified_;         ///是否已经通过了管理服务器的验证
                uint8_t host_type_;     ///eNetServiceType
                void *host_ptr_;
};

#endif

